<template>
  <div v-if="this.$store.getters.siteId !== 'BR'">
    <el-select v-model="lang" placeholder="请选择" @change="handleSetLanguage" style="width: 100px" size="mini">
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
  </div>

</template>

<script>
export default {
  computed: {
    language() {
      return this.$store.getters.language
    }
  },
  data(){
    return {
      options: [
        {label: '中文',value: 'zh'},
        {label: 'Español',value: 'es'},
        {label: 'English',value: 'en'},
      ],
      lang: this.$store.getters.language
    }
  },
  methods: {
    handleSetLanguage() {
      this.$i18n.locale = this.lang
      this.$store.dispatch('app/setLanguage', this.lang)
      this.$message({
        message: 'Switch Language Success',
        type: 'success'
      })
    }
  }
}
</script>
